from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.ods.oms.yl_oms_oms_waybill import jms_ods__yl_oms_oms_waybill
from jms.dim.dim_lmdm_sys_network_expand import jms_dim__dim_lmdm_sys_network_expand

jms_dwd__dwd_customer_network_waybill_summary_dt = SparkSqlOperator(
    task_id='jms_dwd__dwd_customer_network_waybill_summary_dt',
    email=['yushuo@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_dwd__dwd_customer_network_waybill_summary_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dwd/dwd_customer_network_waybill_summary_dt/execute.sql',
    pool_slots=6,
    executor_cores=2 , 
    executor_memory='2G' , 
    driver_memory='3G' , 
    num_executors=2 , 
    conf={
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.shuffle.service.enabled': 'true',
          'spark.sql.shuffle.partitions': 600
          },
    # hiveconf={'hive.exec.dynamic.partition': 'true',
    #           'hive.exec.dynamic.partition.mode': 'nonstrict',
    #           'hive.exec.max.dynamic.partitions.pernode': 20,
    #           'hive.exec.max.dynamic.partitions': 20
    #           },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=60),
)

jms_dwd__dwd_customer_network_waybill_summary_dt << [
    jms_ods__yl_oms_oms_waybill,
    jms_dim__dim_lmdm_sys_network_expand
]


